import { myAjax } from '@/utils/ajax'
import Cookies from 'js-cookie'
/**
 * 获取登录图形验证码
 */
export function getValidateCodeImage (uuid) {
  return myAjax({
    url: '/system/user/get_login_code',
    data: { uuid },
    responseType: 'blob'
  })
}

/**
 * 登录
 */
export function userLogin (data) {
  return myAjax({
    url: '/system/user/login',
    data
  })
}

/**
 * 登出
 */
export function userLogout () {
  return myAjax({
    url: '/system/user/logout',
    data: {
      ftoken: Cookies.get('token')
    },
    loadingDom: 'body',
    loadingObj: {
      lock: true,
      text: '正在退出',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    }
  })
}

/**
 * 获取验证码
 *
 */
export function getVerifyCode (phone) {
  return myAjax({
    url: '/system/user/get_code_for_forget_password',
    data: {
      phone: phone
    }
  })
}

/**
 * 修改密码
 */
export function forgetPassword (data) {
  return myAjax({
    url: '/system/user/forget_password',
    data
  })
}

/**
 * 修改密码
 */
export function fixPassword (data) {
  return myAjax({
    url: '/system/user/change_password',
    data
  })
}

/**
 * 退出登录
 */
export function logout () {
  return myAjax({
    url: '/system/user/logout',
    data: {
      token: Cookies.get('token')
    }
  })
}
